import { action, observable } from 'mobx-miniprogram'

export const currentUserStore = observable({
  // 数据字段
  id: 1,
  username: '默认用户',
  gender: 0,
  avatar: 'https://img.yzcdn.cn/vant/cat.jpeg',
  description: '用户很神秘，什么都没有写~',
  openId: 'openId-01',
  wechatId: 'wechatId-01',
  qqId: 'qqId-01',
  tags: '["伙伴星球"]',
  createTime: '',
  // action方法，用于修改数据
  updateUserName: action(function(username) {
    this.username = username
  }),
  updateGender: action(function(gender) {
    this.gender = gender
  }),
  updateAvatar: action(function(avatar) {
    this.avatar = avatar
  }),
  updateDescription: action(function(description) {
    this.description = description
  }),
  updateWeChatId: action(function(weChatId) {
    this.weChatId = weChatId
  }),
  updateQQId: action(function(qqId) {
    this.qqId = qqId
  }),
  updateTags: action(function(tags) {
    this.tags = tags
  }),
  updateCurrentUser: action(function(currentUser) {
    this.id = currentUser.id
    this.username = currentUser.username
    this.gender = currentUser.gender
    this.avatar = currentUser.avatar
    this.description = currentUser.description
    this.openId = currentUser.openId
    this.wechatId = currentUser.wechatId
    this.qqId = currentUser.qqId
    this.tags = currentUser.tags
    this.createTime = currentUser.createTime
  }),
  clearData: action(function() {
    this.id = 1,
    this.username = '默认用户',
    this.gender = 0,
    this.avatar = 'https://img.yzcdn.cn/vant/cat.jpeg',
    this.description = '用户很神秘，什么都没有写~',
    this.openId = 'openId-01',
    this.wechatId = 'wechatId-01',
    this.qqId = 'qqId-01',
    this.tags = '["伙伴星球"]',
    this.createTime = ''
  })
})